// pages/searchAddress/searchAddress.js
const request = require('../../utils/request.js').request;
Page({


    /**
     * 页面的初始数据
     */
    data: {
        searchVal: '',
        hotTags: [],
        quickTags: []

    },
    //快捷搜索
    getHotTags: function () {
        var that = this;
        let params = {
            labelType: "hot_keywords"
        }
        request('/m/get/label/by/type.json', params).then(function (res) {
            console.log(res)
            that.setData({
                hotTags: res.data.result
            })
        })
    },
    //活动类型
    getQuickTags: function () {
        wx.showLoading({
            title: '加载中...',
            mask: true
        })
        var that = this;
        let params = {
            labelType: "activity_type"
        }
        request('/m/get/label/by/type.json', params).then(function (res) {
            console.log(res);
            wx.hideLoading();
            that.setData({
                quickTags: res.data.result
            })
        })
    },
    //点击事件
    getkeywords: function (e) {
        var that = this;

        that.setData({
            searchVal: e.currentTarget.dataset.val
        }, function () {
            //console.log(that.data.searchVal)
            wx.navigateTo({
                url: '../result/result?keyword=' + that.data.searchVal
            })
        })


    },
    searchSubmit: function (event) {
        wx.navigateTo({
            url: '../result/result?keyword=' + event.detail.value
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getHotTags();
        this.getQuickTags();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})